setSyncPaused(true);
for(const auto &oneFolder : folders) {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
const auto fileInfo = QFileInfo{localPath + oneFolder->_file};
const auto parentFolderPath = fileInfo.dir().absolutePath();
const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
-#endif
if (oneFolder->_type == ItemType::ItemTypeDirectory) {
FileSystem::removeRecursively(localPath + oneFolder->_file);
} else {
item->_instruction = CSYNC_INSTRUCTION_ERROR;
item->_errorString = tr("Not allowed because you don't have permission to add subfolders to that folder");
const auto localPath = QString{_discoveryData->_localDir + item->_file};
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
qCWarning(lcDisco) << "unexpected new folder in a read-only folder will be made read-write" << localPath;
FileSystem::setFolderPermissions(localPath, FileSystem::FolderPermissions::ReadWrite);
emit _discoveryData->remnantReadOnlyFolderDiscovered(item);
-#endif
return false;
} else if (!item->isDirectory() && !perms.hasPermission(RemotePermissions::CanAddFile)) {
qCWarning(lcDisco) << "checkForPermission: ERROR" << item->_file;
_dirItem->_instruction = CSYNC_INSTRUCTION_ERROR;
_dirItem->_errorString = tr("Not allowed because you don't have permission to add subfolders to that folder");
const auto localPath = QString{_discoveryData->_localDir + _dirItem->_file};
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
qCWarning(lcDisco) << "unexpected new folder in a read-only folder will be made read-write" << localPath;
FileSystem::setFolderPermissions(localPath, FileSystem::FolderPermissions::ReadWrite);
emit _discoveryData->remnantReadOnlyFolderDiscovered(_dirItem);
-#endif
}
_dirItem->_direction = _dirItem->_direction == SyncFileItem::Up ? SyncFileItem::Down : SyncFileItem::Up;
} else {
QString removeError;
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
const auto fileInfo = QFileInfo{di.filePath()};
const auto parentFolderPath = fileInfo.dir().absolutePath();
const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
-#endif
removeOk = FileSystem::remove(di.filePath(), &removeError);
if (removeOk) {
if (onDeleted)
allRemoved = false;
}
if (allRemoved) {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
const auto fileInfo = QFileInfo{path};
const auto parentFolderPath = fileInfo.dir().absolutePath();
const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
FileSystem::setFolderPermissions(path, FileSystem::FolderPermissions::ReadWrite);
-#endif
allRemoved = QDir().rmdir(path);
if (allRemoved) {
if (onDeleted)
return false;
}
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
bool FileSystem::setFolderPermissions(const QString &path,
FileSystem::FolderPermissions permissions) noexcept
{
}
}
-#endif
-
} // namespace OCC
bool OWNCLOUDSYNC_EXPORT setFolderPermissions(const QString &path,
FileSystem::FolderPermissions permissions) noexcept;
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
bool OWNCLOUDSYNC_EXPORT isFolderReadOnly(const std::filesystem::path &path) noexcept;
-#endif
}
/** @} */
|| _item->_instruction == CSYNC_INSTRUCTION_NEW
|| _item->_instruction == CSYNC_INSTRUCTION_UPDATE_METADATA) {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
if (!_item->_remotePerm.isNull() &&
!_item->_remotePerm.hasPermission(RemotePermissions::CanAddFile) &&
!_item->_remotePerm.hasPermission(RemotePermissions::CanAddSubDirectories)) {
_item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg("", tr("unknown exception"));
}
}
-#endif
if (!_item->_isAnyCaseClashChild && !_item->_isAnyInvalidCharChild) {
if (_item->isEncrypted()) {
_item->_e2eCertificateFingerprint = propagator()->account()->encryptionCertificateFingerprint();
void PropagateDownloadFile::done(const SyncFileItem::Status status, const QString &errorString, const ErrorCategory category)
{
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
if (_needParentFolderRestorePermissions) {
FileSystem::setFolderPermissions(QString::fromStdWString(_parentPath.wstring()), FileSystem::FolderPermissions::ReadOnly);
emit propagator()->touchedFile(QString::fromStdWString(_parentPath.wstring()));
_needParentFolderRestorePermissions = false;
}
-#endif
PropagateItemJob::done(status, errorString, category);
}
void PropagateDownloadFile::makeParentFolderModifiable(const QString &fileName)
{
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
try {
const auto newDirPath = std::filesystem::path{fileName.toStdWString()};
Q_ASSERT(newDirPath.has_parent_path());
emit propagator()->touchedFile(QString::fromStdWString(_parentPath.wstring()));
_needParentFolderRestorePermissions = true;
}
-#endif
}
const char owncloudCustomSoftErrorStringC[] = "owncloud-custom-soft-error-string";
return;
}
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
if (_needParentFolderRestorePermissions) {
FileSystem::setFolderPermissions(QString::fromStdWString(_parentPath.wstring()), FileSystem::FolderPermissions::ReadOnly);
emit propagator()->touchedFile(QString::fromStdWString(_parentPath.wstring()));
_needParentFolderRestorePermissions = false;
}
-#endif
FileSystem::setFileHidden(filename, false);
#include <QBuffer>
#include <QFile>
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
#include <filesystem>
-#endif
namespace OCC {
class PropagateDownloadEncrypted;
PropagateDownloadEncrypted *_downloadEncryptedHelper = nullptr;
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
std::filesystem::path _parentPath;
-#endif
bool _needParentFolderRestorePermissions = false;
};
}
#include <qstack.h>
#include <QCoreApplication>
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
#include <filesystem>
-#endif
#include <ctime>
QString absolute = propagator()->fullLocalPath(_item->_file + path);
QStringList errors;
QList<QPair<QString, bool>> deleted;
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
const auto fileInfo = QFileInfo{absolute};
const auto parentFolderPath = fileInfo.dir().absolutePath();
const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
FileSystem::setFolderPermissions(absolute, FileSystem::FolderPermissions::ReadWrite);
-#endif
bool success = FileSystem::removeRecursively(
absolute,
[&deleted](const QString &path, bool isDir) {
}
} else {
if (FileSystem::fileExists(filename)) {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
const auto fileInfo = QFileInfo{filename};
const auto parentFolderPath = fileInfo.dir().absolutePath();
const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
-#endif
if (!FileSystem::remove(filename, &removeError)) {
done(SyncFileItem::NormalError, removeError, ErrorCategory::GenericError);
return;
}
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
auto parentFolderPath = std::filesystem::path{};
auto parentNeedRollbackPermissions = false;
try {
{
qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights";
}
-#endif
emit propagator()->touchedFile(newDirStr);
QDir localDir(propagator()->localPath());
return;
}
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
if (!_item->_remotePerm.isNull() &&
!_item->_remotePerm.hasPermission(RemotePermissions::CanAddFile) &&
!_item->_remotePerm.hasPermission(RemotePermissions::CanAddSubDirectories)) {
{
qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights";
}
-#endif
// Insert the directory into the database. The correct etag will be set later,
// once all contents have been propagated, because should_update_metadata is true.
return;
}
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
auto targetParentFolderPath = std::filesystem::path{};
auto targetParentFolderWasReadOnly = false;
try {
};
const auto folderPermissionsHandler = FileSystem::FilePermissionsRestore{existingFile, FileSystem::FolderPermissions::ReadWrite};
-#endif
emit propagator()->touchedFile(existingFile);
emit propagator()->touchedFile(targetFile);
if (QString renameError; !FileSystem::rename(existingFile, targetFile, &renameError)) {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
if (targetParentFolderWasReadOnly) {
restoreTargetPermissions(targetParentFolderPath);
}
if (originParentFolderWasReadOnly) {
restoreTargetPermissions(originParentFolderPath);
}
-#endif
done(SyncFileItem::NormalError, renameError, ErrorCategory::GenericError);
return;
}
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
if (targetParentFolderWasReadOnly) {
restoreTargetPermissions(targetParentFolderPath);
}
if (originParentFolderWasReadOnly) {
restoreTargetPermissions(originParentFolderPath);
}
-#endif
}
SyncJournalFileRecord oldRecord;
#include <QJsonValue>
#include <memory>
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
#include <filesystem>
-#endif
PathComponents::PathComponents(const char *path)
: PathComponents { QString::fromUtf8(path) }
if (fi.isFile()) {
QVERIFY(_rootDir.remove(relativePath));
} else {
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
const auto pathToDelete = fi.filePath().toStdWString();
std::filesystem::permissions(pathToDelete, std::filesystem::perms::owner_exec, std::filesystem::perm_options::add);
QVERIFY(std::filesystem::remove_all(pathToDelete));
-#endif
}
}
#include <QtTest>
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
#include <filesystem>
-#endif
#include <iostream>
using namespace OCC;
QStandardPaths::setTestModeEnabled(true);
}
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
void t7pl()
{
FakeFolder fakeFolder{ FileInfo() };
QCOMPARE(count, 2);
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
-#endif
static void setAllPerm(FileInfo *fi, OCC::RemotePermissions perm)
{
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
-#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
static void demo_perms(std::filesystem::perms p)
{
using std::filesystem::perms;
QVERIFY(ensureReadOnlyItem("/readOnlyFolder/test/newFile.txt"));
QVERIFY(ensureReadOnlyItem("/readOnlyFolder/newFolder"));
}
-#endif
};
QTEST_GUILESS_MAIN(TestPermissions)